﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data;
namespace DnDDB
{
    public class TableSetup
    {
        public static void alignmentSetup()
        {
            string dbcommand;
            getMySQL sql = new getMySQL();
            Dictionary<string, int> alignment_dictionary = new Dictionary<string, int>();
            alignment_dictionary.Add("Lawful Good", 1);
            alignment_dictionary.Add("Neutral Good", 2);
            alignment_dictionary.Add("Chaotic Good", 3);
            alignment_dictionary.Add("Lawful Neutral", 4);
            alignment_dictionary.Add("True Neutral", 5);
            alignment_dictionary.Add("Chaotic Neutral", 6);
            alignment_dictionary.Add("Lawful Evil", 7);
            alignment_dictionary.Add("Neutral Evil", 8);
            alignment_dictionary.Add("Chaotic Evil", 9);
            foreach (KeyValuePair<string, int> pair in alignment_dictionary)
            {
                dbcommand = "Select * from alignment where id='" + pair.Value + "';";
                DataTable tb = sql.GetMySQLFilledTable(dbcommand);
                if (tb.Rows.Count == 0)
                {
                    dbcommand = "INSERT INTO alignment VALUES ('" + pair.Value + "', '" + pair.Key + "');";
                    sql.GetMySQLExecuteNonQuery(dbcommand);
                }
            }
        }
        public static void raceSetup()
        {
            string dbcommand;
            getMySQL sql = new getMySQL();
            string[] race_array = new string[] {"Human", "Elf", "Gnome", "Half-Orc", "Half-Elf", "Dark Elf", "Halfling"};
            foreach (string race in race_array)
            {
                dbcommand = "Select * from race where name='" + race + "';";
                DataTable tb = sql.GetMySQLFilledTable(dbcommand);
                if (tb.Rows.Count == 0)
                {
                    dbcommand = "INSERT INTO race VALUES ('" + race + "', '0', '0', '0', '0', '0', '0');";
                    sql.GetMySQLExecuteNonQuery(dbcommand);
                }
            }
        }

        public static void skillSetup()
        {
            string dbcommand;
            getMySQL sql = new getMySQL();
            string[] skill_array = new string[] {
                "Appraise", 
                "Balance",
                "Bluff",
                "Climb",
                "Concentration",
                "Craft",
                "Decipher Script",
                "Diplomacy",
                "Disable Device",
                "Disguise",
                "Escape Artist",
                "Forgery",
                "Gather Information",
                "Handle Animal",
                "Heal",
                "Hide",
                "Intimidate",
                "Jump",
                "Knowledge",
                "Listen",
                "Move Silently",
                "Open Lock",
                "Perform",
                "Profession",
                "Ride",
                "Search",
                "Senes Motive",
                "Sleight of Hand",
                "Speak Language",
                "Spellcraft",
                "Spot",
                "Survival",
                "Swim",
                "Tumble",
                "Use Magic Device",
                "Use Rope"
            };
            foreach (string skill in skill_array)
            {
                dbcommand = "Select * from skill where name='" + skill + "';";
                DataTable tb = sql.GetMySQLFilledTable(dbcommand);
                if (tb.Rows.Count == 0)
                {
                    dbcommand = "INSERT INTO skill (name) VALUES ('" + skill + "');";
                    sql.GetMySQLExecuteNonQuery(dbcommand);
                }
            }
        }
    }
}
